from django.db import models
from django.contrib.auth.models import AbstractUser


class User(AbstractUser):
    mobile = models.CharField(max_length=11)

    def __str__(self):
        return self.username

    class Meta:
        db_table = 'user'


# 收件地址表 Addr
class Addr(models.Model):
    receiver = models.CharField(max_length=30, verbose_name='收货人')
    receiver_mobile = models.CharField(max_length=11, verbose_name='手机号')
    receiver_addr = models.CharField(max_length=100, verbose_name='收货地址')
    is_default = models.BooleanField(default=False, verbose_name='默认地址')
    user = models.ForeignKey(to=User, on_delete=models.CASCADE, verbose_name='用户')

    def __str__(self):
        return self.receiver + " " + self.receiver_mobile + " " + self.receiver_addr

    class Meta:
        db_table = 'addr_t'
        verbose_name = '收货地址表'







